package cn.faster.common.exception;

import cn.faster.common.enums.CodeEnum;
import lombok.Getter;
import lombok.Setter;

/**
 * 自定义业务异常
 */
@Getter
@Setter
public class BusinessRuntimeException extends RuntimeException {

    /**
     * 结果码
     */
    private final String code;

    /**
     * 结果码描述
     */
    private final String description;

    /**
     * 结果码枚举
     */
    private CodeEnum codeEnum;


    public BusinessRuntimeException(CodeEnum codeEnum) {
        super(codeEnum.getDescription());
        this.code = codeEnum.getCode();
        this.description = codeEnum.getDescription();
        this.codeEnum = codeEnum;
    }

    public void setResultCode(CodeEnum resultCode) {
        this.codeEnum = resultCode;
    }

    public CodeEnum getCodeEnum() {
        return codeEnum;
    }
}